<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>sampleFile - OpenGrok cross reference for /sampleFile</title></head><body>
<script type="text/javascript">/* <![CDATA[ */
function get_sym_list(){return [["Package","xp",[["fzf",23]]],["Struct","xs",[["Reader",36]]]];} /* ]]> */</script><a class="l" name="1" href="#1">1</a><span class="c">// The MIT License (MIT)</span>
<a class="l" name="2" href="#2">2</a><span class="c">//</span>
<a class="l" name="3" href="#3">3</a><span class="c">// Copyright (c) 2016 Junegunn Choi</span>
<a class="l" name="4" href="#4">4</a><span class="c">//</span>
<a class="l" name="5" href="#5">5</a><span class="c">// Permission is hereby granted, free of charge, to any person obtaining a copy</span>
<a class="l" name="6" href="#6">6</a><span class="c">// of this software and associated documentation files (the &quot;Software&quot;), to deal</span>
<a class="l" name="7" href="#7">7</a><span class="c">// in the Software without restriction, including without limitation the rights</span>
<a class="l" name="8" href="#8">8</a><span class="c">// to use, copy, modify, merge, publish, distribute, sublicense, <a href="/source/s?path=and/">and</a>/<a href="/source/s?path=and/or">or</a> sell</span>
<a class="l" name="9" href="#9">9</a><span class="c">// copies of the Software, and to permit persons to whom the Software is</span>
<a class="hl" name="10" href="#10">10</a><span class="c">// furnished to do so, subject to the following conditions:</span>
<a class="l" name="11" href="#11">11</a><span class="c">//</span>
<a class="l" name="12" href="#12">12</a><span class="c">// The above copyright notice and this permission notice shall be included in</span>
<a class="l" name="13" href="#13">13</a><span class="c">// all copies or substantial portions of the Software.</span>
<a class="l" name="14" href="#14">14</a><span class="c">//</span>
<a class="l" name="15" href="#15">15</a><span class="c">// THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span>
<a class="l" name="16" href="#16">16</a><span class="c">// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
<a class="l" name="17" href="#17">17</a><span class="c">// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span>
<a class="l" name="18" href="#18">18</a><span class="c">// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
<a class="l" name="19" href="#19">19</a><span class="c">// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span>
<a class="hl" name="20" href="#20">20</a><span class="c">// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN</span>
<a class="l" name="21" href="#21">21</a><span class="c">// THE SOFTWARE.</span>
<a class="l" name="22" href="#22">22</a>
<a class="l" name="23" href="#23">23</a><b>package</b> <a class="xp" name="fzf"/><a href="/source/s?refs=fzf" class="xp intelliWindow-symbol" data-definition-place="def">fzf</a>
<a class="l" name="24" href="#24">24</a>
<a class="l" name="25" href="#25">25</a><b>import</b> (
<a class="l" name="26" href="#26">26</a>	<span class="s">&quot;bufio&quot;</span>
<a class="l" name="27" href="#27">27</a>	<span class="s">&quot;io&quot;</span>
<a class="l" name="28" href="#28">28</a>	<span class="s">&quot;os&quot;</span>
<a class="l" name="29" href="#29">29</a>	<span class="s">&quot;<a href="/source/s?path=sync/">sync</a>/<a href="/source/s?path=sync/atomic">atomic</a>&quot;</span>
<a class="hl" name="30" href="#30">30</a>	<span class="s">&quot;time&quot;</span>
<a class="l" name="31" href="#31">31</a>
<a class="l" name="32" href="#32">32</a>	<span class="s">&quot;<a href="/source/s?path=github.com/">github.com</a>/<a href="/source/s?path=github.com/junegunn/">junegunn</a>/<a href="/source/s?path=github.com/junegunn/fzf/">fzf</a>/<a href="/source/s?path=github.com/junegunn/fzf/src/">src</a>/<a href="/source/s?path=github.com/junegunn/fzf/src/util">util</a>&quot;</span>
<a class="l" name="33" href="#33">33</a>)
<a class="l" name="34" href="#34">34</a>
<a class="l" name="35" href="#35">35</a><span class="c">// Reader reads from command or standard input</span>
<a class="l" name="36" href="#36">36</a><b>type</b> <a class="xs" name="Reader"/><a href="/source/s?refs=Reader" class="xs intelliWindow-symbol" data-definition-place="def">Reader</a> <b>struct</b> {
<a class="l" name="37" href="#37">37</a>	<a class="xmb" name="pusher"/><a href="/source/s?refs=pusher" class="xmb intelliWindow-symbol" data-definition-place="def">pusher</a>   <b>func</b>([]<b>byte</b>) <b>bool</b>
<a class="l" name="38" href="#38">38</a>	<a class="xmb" name="eventBox"/><a href="/source/s?refs=eventBox" class="xmb intelliWindow-symbol" data-definition-place="def">eventBox</a> *<a href="/source/s?defs=util" class="intelliWindow-symbol" data-definition-place="undefined-in-file">util</a>.<a class="d intelliWindow-symbol" href="#EventBox" data-definition-place="defined-in-file">EventBox</a>
<a class="l" name="39" href="#39">39</a>	<a class="xmb" name="delimNil"/><a href="/source/s?refs=delimNil" class="xmb intelliWindow-symbol" data-definition-place="def">delimNil</a> <b>bool</b>
<a class="hl" name="40" href="#40">40</a>	<a class="xmb" name="event"/><a href="/source/s?refs=event" class="xmb intelliWindow-symbol" data-definition-place="def">event</a>    <b>int32</b>
<a class="l" name="41" href="#41">41</a>}
<a class="l" name="42" href="#42">42</a>
<a class="l" name="43" href="#43">43</a><span class="c">// NewReader returns new Reader object</span>
<a class="l" name="44" href="#44">44</a><b>func</b> <a class="d" name="NewReader"/><a href="/source/s?refs=NewReader" class="d intelliWindow-symbol" data-definition-place="def">NewReader</a>(<a class="d intelliWindow-symbol" href="#pusher" data-definition-place="defined-in-file">pusher</a> <b>func</b>([]<b>byte</b>) <b>bool</b>, <a class="d intelliWindow-symbol" href="#eventBox" data-definition-place="defined-in-file">eventBox</a> *<a href="/source/s?defs=util" class="intelliWindow-symbol" data-definition-place="undefined-in-file">util</a>.<a class="xa" name="EventBox"/><a href="/source/s?refs=EventBox" class="xa intelliWindow-symbol" data-definition-place="def">EventBox</a>, <a class="d intelliWindow-symbol" href="#delimNil" data-definition-place="defined-in-file">delimNil</a> <b>bool</b>) *<a href="/source/s?defs=Reader" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Reader</a> {
<a class="l" name="45" href="#45">45</a>	<b>return</b> &amp;<a href="/source/s?defs=Reader" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Reader</a>{<a class="d intelliWindow-symbol" href="#pusher" data-definition-place="defined-in-file">pusher</a>, <a class="d intelliWindow-symbol" href="#eventBox" data-definition-place="defined-in-file">eventBox</a>, <a class="d intelliWindow-symbol" href="#delimNil" data-definition-place="defined-in-file">delimNil</a>, <b>int32</b>(<a href="/source/s?defs=EvtReady" class="intelliWindow-symbol" data-definition-place="undefined-in-file">EvtReady</a>)}
<a class="l" name="46" href="#46">46</a>}
<a class="l" name="47" href="#47">47</a>
<a class="l" name="48" href="#48">48</a><b>func</b> (<a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a> *<a href="/source/s?defs=Reader" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Reader</a>) <a class="d" name="startEventPoller"/><a href="/source/s?refs=startEventPoller" class="d intelliWindow-symbol" data-definition-place="def">startEventPoller</a>() {
<a class="l" name="49" href="#49">49</a>	<b>go</b> <b>func</b>() {
<a class="hl" name="50" href="#50">50</a>		<a href="/source/s?defs=ptr" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ptr</a> := &amp;<a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a>.<a class="d intelliWindow-symbol" href="#event" data-definition-place="defined-in-file">event</a>
<a class="l" name="51" href="#51">51</a>		<a href="/source/s?defs=pollInterval" class="intelliWindow-symbol" data-definition-place="undefined-in-file">pollInterval</a> := <a href="/source/s?defs=readerPollIntervalMin" class="intelliWindow-symbol" data-definition-place="undefined-in-file">readerPollIntervalMin</a>
<a class="l" name="52" href="#52">52</a>		<b>for</b> {
<a class="l" name="53" href="#53">53</a>			<b>if</b> <a href="/source/s?defs=atomic" class="intelliWindow-symbol" data-definition-place="undefined-in-file">atomic</a>.<a href="/source/s?defs=CompareAndSwapInt32" class="intelliWindow-symbol" data-definition-place="undefined-in-file">CompareAndSwapInt32</a>(<a href="/source/s?defs=ptr" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ptr</a>, <b>int32</b>(<a href="/source/s?defs=EvtReadNew" class="intelliWindow-symbol" data-definition-place="undefined-in-file">EvtReadNew</a>), <b>int32</b>(<a href="/source/s?defs=EvtReady" class="intelliWindow-symbol" data-definition-place="undefined-in-file">EvtReady</a>)) {
<a class="l" name="54" href="#54">54</a>				<a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a>.<a class="d intelliWindow-symbol" href="#eventBox" data-definition-place="defined-in-file">eventBox</a>.<a href="/source/s?defs=Set" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Set</a>(<a href="/source/s?defs=EvtReadNew" class="intelliWindow-symbol" data-definition-place="undefined-in-file">EvtReadNew</a>, <b>true</b>)
<a class="l" name="55" href="#55">55</a>				<a href="/source/s?defs=pollInterval" class="intelliWindow-symbol" data-definition-place="undefined-in-file">pollInterval</a> = <a href="/source/s?defs=readerPollIntervalMin" class="intelliWindow-symbol" data-definition-place="undefined-in-file">readerPollIntervalMin</a>
<a class="l" name="56" href="#56">56</a>			} <b>else</b> <b>if</b> <a href="/source/s?defs=atomic" class="intelliWindow-symbol" data-definition-place="undefined-in-file">atomic</a>.<a href="/source/s?defs=LoadInt32" class="intelliWindow-symbol" data-definition-place="undefined-in-file">LoadInt32</a>(<a href="/source/s?defs=ptr" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ptr</a>) == <b>int32</b>(<a href="/source/s?defs=EvtReadFin" class="intelliWindow-symbol" data-definition-place="undefined-in-file">EvtReadFin</a>) {
<a class="l" name="57" href="#57">57</a>				<b>return</b>
<a class="l" name="58" href="#58">58</a>			} <b>else</b> {
<a class="l" name="59" href="#59">59</a>				<a href="/source/s?defs=pollInterval" class="intelliWindow-symbol" data-definition-place="undefined-in-file">pollInterval</a> += <a href="/source/s?defs=readerPollIntervalStep" class="intelliWindow-symbol" data-definition-place="undefined-in-file">readerPollIntervalStep</a>
<a class="hl" name="60" href="#60">60</a>				<b>if</b> <a href="/source/s?defs=pollInterval" class="intelliWindow-symbol" data-definition-place="undefined-in-file">pollInterval</a> &gt; <a href="/source/s?defs=readerPollIntervalMax" class="intelliWindow-symbol" data-definition-place="undefined-in-file">readerPollIntervalMax</a> {
<a class="l" name="61" href="#61">61</a>					<a href="/source/s?defs=pollInterval" class="intelliWindow-symbol" data-definition-place="undefined-in-file">pollInterval</a> = <a href="/source/s?defs=readerPollIntervalMax" class="intelliWindow-symbol" data-definition-place="undefined-in-file">readerPollIntervalMax</a>
<a class="l" name="62" href="#62">62</a>				}
<a class="l" name="63" href="#63">63</a>			}
<a class="l" name="64" href="#64">64</a>			<a href="/source/s?defs=time" class="intelliWindow-symbol" data-definition-place="undefined-in-file">time</a>.<a href="/source/s?defs=Sleep" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Sleep</a>(<a href="/source/s?defs=pollInterval" class="intelliWindow-symbol" data-definition-place="undefined-in-file">pollInterval</a>)
<a class="l" name="65" href="#65">65</a>		}
<a class="l" name="66" href="#66">66</a>	}()
<a class="l" name="67" href="#67">67</a>}
<a class="l" name="68" href="#68">68</a>
<a class="l" name="69" href="#69">69</a><b>func</b> (<a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a> *<a href="/source/s?defs=Reader" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Reader</a>) <a class="d" name="fin"/><a href="/source/s?refs=fin" class="d intelliWindow-symbol" data-definition-place="def">fin</a>(<a href="/source/s?defs=success" class="intelliWindow-symbol" data-definition-place="undefined-in-file">success</a> <b>bool</b>) {
<a class="hl" name="70" href="#70">70</a>	<a href="/source/s?defs=atomic" class="intelliWindow-symbol" data-definition-place="undefined-in-file">atomic</a>.<a href="/source/s?defs=StoreInt32" class="intelliWindow-symbol" data-definition-place="undefined-in-file">StoreInt32</a>(&amp;<a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a>.<a class="d intelliWindow-symbol" href="#event" data-definition-place="defined-in-file">event</a>, <b>int32</b>(<a href="/source/s?defs=EvtReadFin" class="intelliWindow-symbol" data-definition-place="undefined-in-file">EvtReadFin</a>))
<a class="l" name="71" href="#71">71</a>	<a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a>.<a class="d intelliWindow-symbol" href="#eventBox" data-definition-place="defined-in-file">eventBox</a>.<a href="/source/s?defs=Set" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Set</a>(<a href="/source/s?defs=EvtReadFin" class="intelliWindow-symbol" data-definition-place="undefined-in-file">EvtReadFin</a>, <a href="/source/s?defs=success" class="intelliWindow-symbol" data-definition-place="undefined-in-file">success</a>)
<a class="l" name="72" href="#72">72</a>}
<a class="l" name="73" href="#73">73</a>
<a class="l" name="74" href="#74">74</a><span class="c">// ReadSource reads data from the default command or from standard input</span>
<a class="l" name="75" href="#75">75</a><b>func</b> (<a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a> *<a href="/source/s?defs=Reader" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Reader</a>) <a class="d" name="ReadSource"/><a href="/source/s?refs=ReadSource" class="d intelliWindow-symbol" data-definition-place="def">ReadSource</a>() {
<a class="l" name="76" href="#76">76</a>	<a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a>.<a class="d intelliWindow-symbol" href="#startEventPoller" data-definition-place="defined-in-file">startEventPoller</a>()
<a class="l" name="77" href="#77">77</a>	<b>var</b> <a href="/source/s?defs=success" class="intelliWindow-symbol" data-definition-place="undefined-in-file">success</a> <b>bool</b>
<a class="l" name="78" href="#78">78</a>	<b>if</b> <a href="/source/s?defs=util" class="intelliWindow-symbol" data-definition-place="undefined-in-file">util</a>.<a href="/source/s?defs=IsTty" class="intelliWindow-symbol" data-definition-place="undefined-in-file">IsTty</a>() {
<a class="l" name="79" href="#79">79</a>		<a href="/source/s?defs=cmd" class="intelliWindow-symbol" data-definition-place="undefined-in-file">cmd</a> := <a href="/source/s?defs=os" class="intelliWindow-symbol" data-definition-place="undefined-in-file">os</a>.<a href="/source/s?defs=Getenv" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Getenv</a>(<span class="s">&quot;FZF_DEFAULT_COMMAND&quot;</span>)
<a class="hl" name="80" href="#80">80</a>		<b>if</b> <b>len</b>(<a href="/source/s?defs=cmd" class="intelliWindow-symbol" data-definition-place="undefined-in-file">cmd</a>) == <span class="n">0</span> {
<a class="l" name="81" href="#81">81</a>			<span class="c">// The default command for *nix requires bash</span>
<a class="l" name="82" href="#82">82</a>			<a href="/source/s?defs=success" class="intelliWindow-symbol" data-definition-place="undefined-in-file">success</a> = <a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a>.<a class="d intelliWindow-symbol" href="#readFromCommand" data-definition-place="defined-in-file">readFromCommand</a>(<span class="s">&quot;bash&quot;</span>, <a href="/source/s?defs=defaultCommand" class="intelliWindow-symbol" data-definition-place="undefined-in-file">defaultCommand</a>)
<a class="l" name="83" href="#83">83</a>		} <b>else</b> {
<a class="l" name="84" href="#84">84</a>			<a href="/source/s?defs=success" class="intelliWindow-symbol" data-definition-place="undefined-in-file">success</a> = <a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a>.<a class="d intelliWindow-symbol" href="#readFromCommand" data-definition-place="defined-in-file">readFromCommand</a>(<span class="s">&quot;sh&quot;</span>, <a href="/source/s?defs=cmd" class="intelliWindow-symbol" data-definition-place="undefined-in-file">cmd</a>)
<a class="l" name="85" href="#85">85</a>		}
<a class="l" name="86" href="#86">86</a>	} <b>else</b> {
<a class="l" name="87" href="#87">87</a>		<a href="/source/s?defs=success" class="intelliWindow-symbol" data-definition-place="undefined-in-file">success</a> = <a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a>.<a class="d intelliWindow-symbol" href="#readFromStdin" data-definition-place="defined-in-file">readFromStdin</a>()
<a class="l" name="88" href="#88">88</a>	}
<a class="l" name="89" href="#89">89</a>	<a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a>.<a class="d intelliWindow-symbol" href="#fin" data-definition-place="defined-in-file">fin</a>(<a href="/source/s?defs=success" class="intelliWindow-symbol" data-definition-place="undefined-in-file">success</a>)
<a class="hl" name="90" href="#90">90</a>}
<a class="l" name="91" href="#91">91</a>
<a class="l" name="92" href="#92">92</a><b>func</b> (<a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a> *<a class="xa" name="Reader"/><a href="/source/s?refs=Reader" class="xa intelliWindow-symbol" data-definition-place="def">Reader</a>) <a class="d" name="feed"/><a href="/source/s?refs=feed" class="d intelliWindow-symbol" data-definition-place="def">feed</a>(<a href="/source/s?defs=src" class="intelliWindow-symbol" data-definition-place="undefined-in-file">src</a> <a href="/source/s?defs=io" class="intelliWindow-symbol" data-definition-place="undefined-in-file">io</a>.<a href="/source/s?defs=Reader" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Reader</a>) {
<a class="l" name="93" href="#93">93</a>	<a href="/source/s?defs=delim" class="intelliWindow-symbol" data-definition-place="undefined-in-file">delim</a> := <b>byte</b>(<span class="s">&apos;\n&apos;</span>)
<a class="l" name="94" href="#94">94</a>	<b>if</b> <a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a>.<a class="d intelliWindow-symbol" href="#delimNil" data-definition-place="defined-in-file">delimNil</a> {
<a class="l" name="95" href="#95">95</a>		<a href="/source/s?defs=delim" class="intelliWindow-symbol" data-definition-place="undefined-in-file">delim</a> = <span class="s">&apos;\000&apos;</span>
<a class="l" name="96" href="#96">96</a>	}
<a class="l" name="97" href="#97">97</a>	<a href="/source/s?defs=reader" class="intelliWindow-symbol" data-definition-place="undefined-in-file">reader</a> := <a href="/source/s?defs=bufio" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bufio</a>.<a href="/source/s?defs=NewReaderSize" class="intelliWindow-symbol" data-definition-place="undefined-in-file">NewReaderSize</a>(<a href="/source/s?defs=src" class="intelliWindow-symbol" data-definition-place="undefined-in-file">src</a>, <a href="/source/s?defs=readerBufferSize" class="intelliWindow-symbol" data-definition-place="undefined-in-file">readerBufferSize</a>)
<a class="l" name="98" href="#98">98</a>	<b>for</b> {
<a class="l" name="99" href="#99">99</a>		<span class="c">// ReadBytes returns err != nil if and only if the returned data does not</span>
<a class="hl" name="100" href="#100">100</a>		<span class="c">// end in delim.</span>
<a class="l" name="101" href="#101">101</a>		<a href="/source/s?defs=bytea" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bytea</a>, <a href="/source/s?defs=err" class="intelliWindow-symbol" data-definition-place="undefined-in-file">err</a> := <a href="/source/s?defs=reader" class="intelliWindow-symbol" data-definition-place="undefined-in-file">reader</a>.<a href="/source/s?defs=ReadBytes" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ReadBytes</a>(<a href="/source/s?defs=delim" class="intelliWindow-symbol" data-definition-place="undefined-in-file">delim</a>)
<a class="l" name="102" href="#102">102</a>		<a href="/source/s?defs=byteaLen" class="intelliWindow-symbol" data-definition-place="undefined-in-file">byteaLen</a> := <b>len</b>(<a href="/source/s?defs=bytea" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bytea</a>)
<a class="l" name="103" href="#103">103</a>		<b>if</b> <a href="/source/s?defs=byteaLen" class="intelliWindow-symbol" data-definition-place="undefined-in-file">byteaLen</a> &gt; <span class="n">0</span> || <a href="/source/s?defs=byteaLen" class="intelliWindow-symbol" data-definition-place="undefined-in-file">byteaLen</a> &gt; <span class="n">0xFF</span> {
<a class="l" name="104" href="#104">104</a>			<b>if</b> <a href="/source/s?defs=err" class="intelliWindow-symbol" data-definition-place="undefined-in-file">err</a> == <b>nil</b> {
<a class="l" name="105" href="#105">105</a>				<span class="c">// get rid of carriage return if under Windows:</span>
<a class="l" name="106" href="#106">106</a>				<b>if</b> <a href="/source/s?defs=util" class="intelliWindow-symbol" data-definition-place="undefined-in-file">util</a>.<a href="/source/s?defs=IsWindows" class="intelliWindow-symbol" data-definition-place="undefined-in-file">IsWindows</a>() &amp;&amp; <a href="/source/s?defs=byteaLen" class="intelliWindow-symbol" data-definition-place="undefined-in-file">byteaLen</a> &gt;= <span class="n">2</span> &amp;&amp; <a href="/source/s?defs=bytea" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bytea</a>[<a href="/source/s?defs=byteaLen" class="intelliWindow-symbol" data-definition-place="undefined-in-file">byteaLen</a>-<span class="n">2</span>] == <b>byte</b>(<span class="s">&apos;\r&apos;</span>) {
<a class="l" name="107" href="#107">107</a>					<a href="/source/s?defs=bytea" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bytea</a> = <a href="/source/s?defs=bytea" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bytea</a>[:<a href="/source/s?defs=byteaLen" class="intelliWindow-symbol" data-definition-place="undefined-in-file">byteaLen</a>-<span class="n">2</span>]
<a class="l" name="108" href="#108">108</a>				} <b>else</b> {
<a class="l" name="109" href="#109">109</a>					<a href="/source/s?defs=bytea" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bytea</a> = <a href="/source/s?defs=bytea" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bytea</a>[:<a href="/source/s?defs=byteaLen" class="intelliWindow-symbol" data-definition-place="undefined-in-file">byteaLen</a>-<span class="n">1</span>]
<a class="hl" name="110" href="#110">110</a>				}
<a class="l" name="111" href="#111">111</a>			}
<a class="l" name="112" href="#112">112</a>			<b>if</b> <a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a>.<a class="d intelliWindow-symbol" href="#pusher" data-definition-place="defined-in-file">pusher</a>(<a href="/source/s?defs=bytea" class="intelliWindow-symbol" data-definition-place="undefined-in-file">bytea</a>) {
<a class="l" name="113" href="#113">113</a>				<a href="/source/s?defs=atomic" class="intelliWindow-symbol" data-definition-place="undefined-in-file">atomic</a>.<a href="/source/s?defs=StoreInt32" class="intelliWindow-symbol" data-definition-place="undefined-in-file">StoreInt32</a>(&amp;<a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a>.<a class="d intelliWindow-symbol" href="#event" data-definition-place="defined-in-file">event</a>, <b>int32</b>(<a href="/source/s?defs=EvtReadNew" class="intelliWindow-symbol" data-definition-place="undefined-in-file">EvtReadNew</a>))
<a class="l" name="114" href="#114">114</a>			}
<a class="l" name="115" href="#115">115</a>		}
<a class="l" name="116" href="#116">116</a>		<b>if</b> <a href="/source/s?defs=err" class="intelliWindow-symbol" data-definition-place="undefined-in-file">err</a> != <b>nil</b> {
<a class="l" name="117" href="#117">117</a>			<b>break</b>
<a class="l" name="118" href="#118">118</a>		}
<a class="l" name="119" href="#119">119</a>	}
<a class="hl" name="120" href="#120">120</a>}
<a class="l" name="121" href="#121">121</a>
<a class="l" name="122" href="#122">122</a><b>func</b> (<a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a> *<a href="/source/s?defs=Reader" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Reader</a>) <a class="d" name="readFromStdin"/><a href="/source/s?refs=readFromStdin" class="d intelliWindow-symbol" data-definition-place="def">readFromStdin</a>() <b>bool</b> {
<a class="l" name="123" href="#123">123</a>	<a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a>.<a class="d intelliWindow-symbol" href="#feed" data-definition-place="defined-in-file">feed</a>(<a href="/source/s?defs=os" class="intelliWindow-symbol" data-definition-place="undefined-in-file">os</a>.<a href="/source/s?defs=Stdin" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Stdin</a>)
<a class="l" name="124" href="#124">124</a>	<b>return</b> <b>true</b>
<a class="l" name="125" href="#125">125</a>}
<a class="l" name="126" href="#126">126</a>
<a class="l" name="127" href="#127">127</a><b>func</b> (<a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a> *<a href="/source/s?defs=Reader" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Reader</a>) <a class="d" name="readFromCommand"/><a href="/source/s?refs=readFromCommand" class="d intelliWindow-symbol" data-definition-place="def">readFromCommand</a>(<a href="/source/s?defs=shell" class="intelliWindow-symbol" data-definition-place="undefined-in-file">shell</a> <b>string</b>, <a href="/source/s?defs=cmd" class="intelliWindow-symbol" data-definition-place="undefined-in-file">cmd</a> <b>string</b>) <b>bool</b> {
<a class="l" name="128" href="#128">128</a>	<a href="/source/s?defs=listCommand" class="intelliWindow-symbol" data-definition-place="undefined-in-file">listCommand</a> := <a href="/source/s?defs=util" class="intelliWindow-symbol" data-definition-place="undefined-in-file">util</a>.<a href="/source/s?defs=ExecCommandWith" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ExecCommandWith</a>(<a href="/source/s?defs=shell" class="intelliWindow-symbol" data-definition-place="undefined-in-file">shell</a>, <a href="/source/s?defs=cmd" class="intelliWindow-symbol" data-definition-place="undefined-in-file">cmd</a>)
<a class="l" name="129" href="#129">129</a>	<a href="/source/s?defs=out" class="intelliWindow-symbol" data-definition-place="undefined-in-file">out</a>, <a href="/source/s?defs=err" class="intelliWindow-symbol" data-definition-place="undefined-in-file">err</a> := <a href="/source/s?defs=listCommand" class="intelliWindow-symbol" data-definition-place="undefined-in-file">listCommand</a>.<a href="/source/s?defs=StdoutPipe" class="intelliWindow-symbol" data-definition-place="undefined-in-file">StdoutPipe</a>()
<a class="hl" name="130" href="#130">130</a>	<b>if</b> <a href="/source/s?defs=err" class="intelliWindow-symbol" data-definition-place="undefined-in-file">err</a> != <b>nil</b> {
<a class="l" name="131" href="#131">131</a>		<b>return</b> <b>false</b>
<a class="l" name="132" href="#132">132</a>	}
<a class="l" name="133" href="#133">133</a>	<a href="/source/s?defs=err" class="intelliWindow-symbol" data-definition-place="undefined-in-file">err</a> = <a href="/source/s?defs=listCommand" class="intelliWindow-symbol" data-definition-place="undefined-in-file">listCommand</a>.<a href="/source/s?defs=Start" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Start</a>()
<a class="l" name="134" href="#134">134</a>	<b>if</b> <a href="/source/s?defs=err" class="intelliWindow-symbol" data-definition-place="undefined-in-file">err</a> != <b>nil</b> {
<a class="l" name="135" href="#135">135</a>		<b>return</b> <b>false</b>
<a class="l" name="136" href="#136">136</a>	}
<a class="l" name="137" href="#137">137</a>	<a href="/source/s?defs=r" class="intelliWindow-symbol" data-definition-place="undefined-in-file">r</a>.<a class="d intelliWindow-symbol" href="#feed" data-definition-place="defined-in-file">feed</a>(<a href="/source/s?defs=out" class="intelliWindow-symbol" data-definition-place="undefined-in-file">out</a>)
<a class="l" name="138" href="#138">138</a>	<b>return</b> <a href="/source/s?defs=listCommand" class="intelliWindow-symbol" data-definition-place="undefined-in-file">listCommand</a>.<a href="/source/s?defs=Wait" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Wait</a>() == <b>nil</b>
<a class="l" name="139" href="#139">139</a>}
<a class="hl" name="140" href="#140">140</a><span class="c">/*<a href="http://example.com">http://example.com</a>*/</span>
<a class="l" name="141" href="#141">141</a><b>import</b> (<span class="s">&apos;<a href="http://example.com">http://example.com</a>&apos;</span>)
<a class="l" name="142" href="#142">142</a></body>
</html>
